<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>
<body>

<div id="app">
    <student></student>
    <teacher></teacher>
</div>

<script>
    // 局部组件     没有el配置选项
    let student = {
        template: `
          <div>
          <h2>学生信息</h2>
          <p>
          <p>学生姓名:{{ stuName }}</p>
          <p>学生年龄:{{ age }}</p>
          <p>学生性别:{{ sex }}</p>
          </p>
          </div>`,
        data: function () {
            return {
                stuName: 'jack',
                age: 20,
                sex: '男'
            }
        }
    }

    let teacher = {
        template: `
          <div>
          <h2>教师信息</h2>
          <p>
              <p>教师姓名:{{ teaName }}</p>
              <p>教师年龄:{{ age }}</p>
              <p>教师性别:{{ sex }}</p>
          </p>
          <student></student>
          </div>`,
        data: function () {
            return {
                teaName: 'xiaoming',
                age: 30,
                sex: '男'
            }
        },
        components:{
            "student":student
        }
    }

    // Vue.component("student",student)
    // Vue.component("teacher",teacher)

    //  根组件
    let vm = new Vue({
        el: '#app',
        data: {},
        methods: {},
        components: {  //注册组件   将子组件注册在根组件上
            "student": student,
            "teacher": teacher
        }
    })
</script>
</body>
</html>